{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }
    #id {
        width: 78px;
    }
    .bs-checkbox {
        width: 36px;
        height: 40px
    }
    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }
    #title span {
        float: right;
        margin-left: 3.333px;
    }
    .search {
        margin-bottom: 0px !important;
    }
    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
    #title {
        position: relative;
        padding-right: 50px;
    }
    #title span {
        position: absolute;
        top: 12px;
        right: 10px;
    }
    .userid-btn:hover {
        background-color: #1ab394;
        color: white;
    }
    .fixed-table-toolbar form {
        display: flex;
        justify-content: space-between;
    }
    .fixed-table-toolbar button {
        margin-left: 10px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <form method="get" action="">
                            <div class="pull-left search" style="display: flex;">
                                <input name="start" type="text" id="start" class="form-control layui-input" value="{$start}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{$end}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7;" class="btn btn-default btn-outline" type="submit">搜索</button>
                                    <button style="border-radius:0px; border:1px solid #e5e6e7;" class="btn btn-default btn-outline" type="button" onclick="reloadPageWithoutParams()">清空</button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div style="display:block;clear: both;"></div>
                    <style>
                        .search{
                            position: relative;
                            left:-10px;
                        }
                        .example{
                            margin-top:20px;
                            margin-bottom: 300px;
                        }
                        .example p{
                            line-height: 30px;
                        }
                    </style>
                    <div style="color:red;line-height:25px;">说明：<br/>1.为保障数据准确性，统计筛选起始时间最早为 2025-05-08 00:00:00，该时间点之前的时段数据不参与筛选统计，自然日的起止时间是00:00:00至23:59:59。<br/>2.统计时会自动排除两类用户数据：一是 2025-05-08 00:00:00 前注册 的账号；二是 被手动标记为测试账号 的数据，确保结果更贴合真实业务。<br/>测试账号采用动态补充策略，如有变更，请及时联系相关同事进行调整，已有测试账号公示如下：<p style="line-height: 25px;">{volist name="testMemberInfo" id="uinfo"}<span style="color:blue;margin-right:25px;display: inline-block;width:210px;">{$uinfo.id}({$uinfo.name}({$uinfo.sex}))</span>{/volist}</p>3.充值金额、会员充值均为已付款的数据，提现金额相关均为已审核通过的。支付宝提现，第二天到账，到账与否受人工打款时机和打款状态设置时机影响。<br/>4.若发现统计数据存在明显异常（如金额、人数与实际预期偏差较大），请及时与相关同事沟通核查，避免影响业务判断。</div>
                    <div class="example">
<!--                        <p>总充值金额：{$totalMoney}元，今日充值金额{$totalMoney_today}元，昨日充值金额{$totalMoney_yesday}元</p>-->
<!--                        <p>总会员充值：{$vipMoney}元，今日会员充值{$vipMoney_today}元，昨日会员充值{$vipMoney_yesday}元</p>-->
<!--                        <p>总新增会员：{$newMember}人，今日新增会员{$newMember_today}人，昨日新增会员{$newMember_yesday}人</p>-->
<!--                        <p>总提现金额：{$totalWithdraw}元，今日提现金额{$totalWithdraw_today}元，昨日提现金额{$totalWithdraw_yesday}元</p>-->
<!--                        <p>总到账金额：{$totalArrival}元，今日到账金额{$totalArrival_today}元，昨日到账金额{$totalArrival_yesday}元</p>-->
<!--                        <p>总支付宝提现金额：{$totalWithdraw_zfb}元，今日支付宝提现金额{$totalWithdraw_zfb_today}元，昨日支付宝提现金额{$totalWithdraw_zfb_yesday}元</p>-->
<!--                        <p>总支付宝到账金额：{$totalWithdraw_zfb_arrival}元，今日支付宝到账金额{$totalWithdraw_zfb_arrival_today}，昨日支付宝到账金额{$totalWithdraw_zfb_arrival_yesday}元</p>-->
                        <table class="stat-table">
                            <thead>
                            <tr>
                                <th>数据类型</th>
                                <th>总计</th>
                                <th class="blue">今日</th>
                                <th>昨日</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr class="gradient-row">
                                <td>充值金额</td>
                                <td>{$totalMoney|number_format=2,'.',''} 元</td>
                                <td class="blue">{$totalMoney_today|number_format=2,'.',''} 元</td>
                                <td>{$totalMoney_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            <tr class="gradient-row">
                                <td>会员充值</td>
                                <td>{$vipMoney|number_format=2,'.',''} 元</td>
                                <td class="blue">{$vipMoney_today|number_format=2,'.',''} 元</td>
                                <td>{$vipMoney_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            <tr class="gradient-row member-row">
                                <td>新增会员</td>
                                <td>{$newMember} 人</td>
                                <td class="blue">{$newMember_today} 人</td>
                                <td>{$newMember_yesday} 人</td>
                            </tr>
                            <tr class="gradient-row">
                                <td>提现金额</td>
                                <td>{$totalWithdraw|number_format=2,'.',''} 元</td>
                                <td class="blue">{$totalWithdraw_today|number_format=2,'.',''} 元</td>
                                <td>{$totalWithdraw_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            <tr class="gradient-row">
                                <td>到账金额</td>
                                <td>{$totalArrival|number_format=2,'.',''} 元</td>
                                <td class="blue">{$totalArrival_today|number_format=2,'.',''} 元</td>
                                <td>{$totalArrival_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            <tr class="gradient-row">
                                <td>支付宝提现</td>
                                <td>{$totalWithdraw_zfb|number_format=2,'.',''} 元</td>
                                <td class="blue">{$totalWithdraw_zfb_today|number_format=2,'.',''} 元</td>
                                <td>{$totalWithdraw_zfb_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            <tr class="gradient-row">
                                <td>支付宝到账</td>
                                <td>{$totalWithdraw_zfb_arrival|number_format=2,'.',''} 元</td>
                                <td class="blue">{$totalWithdraw_zfb_arrival_today|number_format=2,'.',''} 元</td>
                                <td>{$totalWithdraw_zfb_arrival_yesday|number_format=2,'.',''} 元</td>
                            </tr>
                            </tbody>
                        </table>

                        <style>
                            .stat-table {
                                width: 80% !important;
                                border-collapse: collapse;
                                margin: 20px 0;
                                font-family: 'Microsoft YaHei', sans-serif;
                            }

                            .stat-table th, .stat-table td {
                                border: 1px solid #e8e8e8;
                                padding: 14px 18px;
                                text-align: left;
                            }

                            .stat-table th {
                                background-color: #f9f9f9;
                                font-weight: 600;
                                color: #333;
                                border-bottom: 2px solid #e0e0e0;
                            }

                            .gradient-row {
                                background: linear-gradient(90deg, #ffffff 0%, #fafafa 100%);
                            }

                            .gradient-row:nth-child(even) {
                                background: linear-gradient(90deg, #fafafa 0%, #ffffff 100%);
                            }

                            .gradient-row:hover {
                                background: linear-gradient(90deg, #f0f5ff 0%, #e6f0ff 100%);
                                transition: background 0.3s ease;
                            }

                            .member-row {
                                background-color: #f9fcf9; /* 会员行单独背景色区分 */
                            }

                            .stat-table .blue {
                                color: #165DFF;
                                font-weight: 600;
                            }

                            /* 响应式优化 */
                            @media (max-width: 768px) {
                                .stat-table th, .stat-table td {
                                    padding: 10px 12px;
                                    font-size: 0.9em;
                                }
                            }
                        </style>
                        <hr/>
                        <p style="color:red;">平台自2025-05-08 00:00:00运行以来且排除上述测试账号数据：</p>
                        <p>平台金币数：{$totalVolley}，计{$totalVolley1}元</p>
                        <p>平台积分数：{$totalScore}，计{$totalScore1}元</p>
                        <br/>
                        <p>平台毛利润公式：总充值金额 + VIP充值金额 - 总提现金额 - (金币数/10*97%) - (积分数/10*92%)</p>
                        <p>平台毛利润：({$totalMoney} + {$vipMoney}) - {$totalWithdraw} - ({$totalVolley} / 10 * 0.97) - ({$totalScore} / 10 * 0.92) = {$totalProfit}元</p>
                    </div>
                </div>
            </div>
            <hr>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(document).ready(function () {
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;

            // 开始时间选择器（限制最小时间为 2025-05-08 00:00:00）
            laydate.render({
                elem: '#start',
                type: 'datetime',
                trigger: 'click',
                min: '2025-05-08 00:00:00', // 固定最小时间
                done: function(value, date) {
                    // 将结束时间的最小可选值设为开始时间（字符串格式）
                    laydate.render({
                        elem: '#end',
                        type: 'datetime',
                        trigger: 'click',
                        min: value, // 直接用字符串，避免日期对象解析问题
                        done: function(endValue, endDate) {
                            // 可选：限制开始时间最大为结束时间
                            laydate.reload('#start', {
                                max: endValue
                            });
                        }
                    });
                    // 如果结束时间小于新的开始时间，清空结束时间
                    if ($('#end').val() && $('#end').val() < value) {
                        $('#end').val('');
                    }
                }
            });

            // 初始化结束时间选择器（无限制，或根据需求设置默认 min）
            laydate.render({
                elem: '#end',
                type: 'datetime',
                trigger: 'click',
                min: '2025-05-08 00:00:00' // 可选：与开始时间保持一致的最小限制
            });

            $('.userid-btn').click(function () {
                var userid = $(this).data('userid');
                $('#userid').val(userid);
                $('#hint').text('正在加载用户' + userid + '的统计数据，请稍候...');

                // 主动提交表单并携带当前时间段参数
                $('form').submit();
            });

            $('form').submit(function (e) {
                var action = $(this).attr('action');
                var formData = $(this).serialize(); // 序列化所有表单参数

                // 处理URL参数合并
                if (formData) {
                    if (action.indexOf('?') === -1) {
                        action += '?' + formData;
                    } else {
                        action += '&' + formData;
                    }
                }

                // 更新表单action为包含所有参数的URL
                $(this).attr('action', action);
                return true;
            });
        });
    });
</script>
<script>
    /**
     * 重载当前页面（不带任何参数）
     */
    function reloadPageWithoutParams() {
        const baseUrl = window.location.origin + window.location.pathname;
        window.location.href = baseUrl;
    }
</script>